package com.chinacache.maint.workorder.entity;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.chinacache.maint.commons.entity.BaseEntity;

@Entity
@Table(name = "WO_WORKORDER_STEP")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class WorkOrderStep extends BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String time;
	private String log;
	private WorkOrder workOrder;
	private Flow flow;
	private String username;
	private Integer isModify;
	private Set<FlowFieldAttribute> flowFieldAttributes = new LinkedHashSet<FlowFieldAttribute>(
			0);
	private Integer order;

	@Column(name = "USER_NAME")
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Id
	@Column(name = "WORKORDER_STEP_ID")
	@GeneratedValue(generator = "SEQ_RPT_USER_TO_CLASS")
	@GenericGenerator(name = "SEQ_RPT_USER_TO_CLASS", strategy = "seqhilo", parameters = { @Parameter(name = "sequence", value = "SEQ_RPT_USER_TO_CLASS") })
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "TIME")
	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	@Column(name = "LOG")
	public String getLog() {
		return log;
	}

	public void setLog(String log) {
		this.log = log;
	}

	@ManyToOne
	@JoinColumn(name = "WORKORDER_ID")
	public WorkOrder getWorkOrder() {
		return workOrder;
	}

	public void setWorkOrder(WorkOrder workOrder) {
		this.workOrder = workOrder;
	}

	@ManyToOne
	@JoinColumn(name = "FLOW_ID")
	public Flow getFlow() {
		return flow;
	}

	public void setFlow(Flow flow) {
		this.flow = flow;
	}

	@OneToMany(mappedBy = "workOrderStep", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
	public Set<FlowFieldAttribute> getFlowFieldAttributes() {
		return flowFieldAttributes;
	}

	public void setFlowFieldAttributes(
			Set<FlowFieldAttribute> flowFieldAttributes) {
		this.flowFieldAttributes = flowFieldAttributes;
	}

	@Column(name = "WOS_ORDER")
	public Integer getOrder() {
		return order;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	@Column(name = "IS_MODIFY")
	public Integer getIsModify() {
		return isModify;
	}

	public void setIsModify(Integer isModify) {
		this.isModify = isModify;
	}
}
